// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.MachineLearning;

public sealed partial class PutCalendarRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>Creates a calendar.</para>
/// </summary>
public sealed partial class PutCalendarRequest : PlainRequest<PutCalendarRequestParameters>
{
	public PutCalendarRequest(Elastic.Clients.Elasticsearch.Serverless.Id calendarId) : base(r => r.Required("calendar_id", calendarId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutCalendar;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_calendar";

	/// <summary>
	/// <para>A description of the calendar.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("description")]
	public string? Description { get; set; }

	/// <summary>
	/// <para>An array of anomaly detection job identifiers.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("job_ids")]
	public ICollection<Elastic.Clients.Elasticsearch.Serverless.Id>? JobIds { get; set; }
}

/// <summary>
/// <para>Creates a calendar.</para>
/// </summary>
public sealed partial class PutCalendarRequestDescriptor : RequestDescriptor<PutCalendarRequestDescriptor, PutCalendarRequestParameters>
{
	internal PutCalendarRequestDescriptor(Action<PutCalendarRequestDescriptor> configure) => configure.Invoke(this);

	public PutCalendarRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Id calendarId) : base(r => r.Required("calendar_id", calendarId))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.MachineLearningPutCalendar;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "ml.put_calendar";

	public PutCalendarRequestDescriptor CalendarId(Elastic.Clients.Elasticsearch.Serverless.Id calendarId)
	{
		RouteValues.Required("calendar_id", calendarId);
		return Self;
	}

	private string? DescriptionValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.Id>? JobIdsValue { get; set; }

	/// <summary>
	/// <para>A description of the calendar.</para>
	/// </summary>
	public PutCalendarRequestDescriptor Description(string? description)
	{
		DescriptionValue = description;
		return Self;
	}

	/// <summary>
	/// <para>An array of anomaly detection job identifiers.</para>
	/// </summary>
	public PutCalendarRequestDescriptor JobIds(ICollection<Elastic.Clients.Elasticsearch.Serverless.Id>? jobIds)
	{
		JobIdsValue = jobIds;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (!string.IsNullOrEmpty(DescriptionValue))
		{
			writer.WritePropertyName("description");
			writer.WriteStringValue(DescriptionValue);
		}

		if (JobIdsValue is not null)
		{
			writer.WritePropertyName("job_ids");
			JsonSerializer.Serialize(writer, JobIdsValue, options);
		}

		writer.WriteEndObject();
	}
}